package guiClasses;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.Observer;

import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder;

import objectClasses.Entry;
import objectClasses.UserInfo;

public class InfoPanel extends GenericPanel
{
	public InfoPanel(final Observer the_o_er, UserInfo other) 
	{
		super(the_o_er);
		buildInfo(other);
	}
	
	public InfoPanel(final Observer the_o_er, UserInfo contestant, Entry entry) 
	{
		super(the_o_er);
	}
	
	public void buildInfo(UserInfo user)
	{
		String type = "";
		switch(user.getUserType())
		{
			case 'A':
				type = "(Attendee)";
				break;
			case 'J':
				type = "(Judge)";
				break;
			case 'C':
				type = "(Contestant)";
				break;
			default:
				break;
		}
		
		JPanel p = new JPanel(new GridBagLayout());
		p.setPreferredSize(new Dimension(436, 232));
		JLabel username = new JLabel("Username: ");
		JLabel username_a = new JLabel(user.getUserName() + " " + type);
		Font f = new Font(username.getFont().getName(),Font.PLAIN, 20); 
		username.setFont(f);
		username_a.setFont(f);
		GridBagConstraints g = GBC.GBCGen(0, 0, 0, 1);
		g.anchor = GridBagConstraints.WEST;
		p.add(username, g);
		g = GBC.GBCGen(0, 0, 1, 1);
		g.anchor = GridBagConstraints.WEST;
		p.add(username_a, g);
		JLabel name = new JLabel("Name: ");
		JLabel name_a = new JLabel(user.getFirstName() + " " + user.getLastName());
		name.setFont(f);
		name_a.setFont(f);
		g = GBC.GBCGen(0, 0, 0, 2);
		g.anchor = GridBagConstraints.WEST;
		p.add(name, g);
		g = GBC.GBCGen(0, 0, 1, 2);
		g.anchor = GridBagConstraints.WEST;
		p.add(name_a, g);
		JLabel email = new JLabel("Email: ");
		JLabel email_a = new JLabel(user.getAddress());
		email.setFont(f);
		email_a.setFont(f);
		g = GBC.GBCGen(0, 0, 0, 3);
		g.anchor = GridBagConstraints.WEST;
		p.add(email, g);
		g = GBC.GBCGen(0, 0, 1, 3);
		g.anchor = GridBagConstraints.WEST;
		p.add(email_a, g);
		JLabel phone = new JLabel("Phone #: ");
		JLabel phone_a = new JLabel(user.getPhoneNumber());
		phone.setFont(f);
		phone_a.setFont(f);
		g = GBC.GBCGen(0, 0, 0, 4);
		g.anchor = GridBagConstraints.WEST;
		p.add(phone, g);
		g = GBC.GBCGen(0, 0, 1, 4);
		g.anchor = GridBagConstraints.WEST;
		p.add(phone_a, g);
		my_panel.add(p, GBC.GBCGen(0, 0, 0, 1));
		my_panel.setBorder(new TitledBorder(user.getUserName() + "'s Information"));
	}
}
